package com.technology.education.ui.common.score_record

import androidx.lifecycle.MutableLiveData
import com.technology.education.data.AppData
import com.technology.education.data.model.DurationRecordModel
import com.technology.education.network.apiService
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import me.hgj.jetpackmvvm.ext.request
import me.hgj.jetpackmvvm.state.ResultState

/**
 *@author:create by BZY
 *Date: 2022/2/28 17
 */
class ScoreRecordViewModel : BaseViewModel() {
    var type = 0
    val result = MutableLiveData<ResultState<DurationRecordModel>>()
    override fun getData() {
        super.getData()
        if (type == 0) {
            //学生的积分记录
            request({
                apiService.billPointList(
                    hashMapOf(
                        "pageNo" to pageIndex,
                        "pageSize" to pageSize
                    )
                )
            }, result)
        } else {
            ///时长记录
            request({
                if (AppData.MEMBER_TYPE == "0") {
                    apiService.billDurationList(
                        hashMapOf(
                            "pageNo" to pageIndex,
                            "pageSize" to pageSize
                        )
                    )
                } else {
                    apiService.billDurationListTeacher(
                        hashMapOf(
                            "pageNo" to pageIndex,
                            "pageSize" to pageSize
                        )
                    )
                }

            }, result)
        }
    }
}